package com.pingbu.common.utils;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
import java.util.Map;

public class PbJsonUtils {

    public static String toSimpleJsonString(Object obj){
        GsonBuilder gb=new GsonBuilder();
        return gb.setDateFormat("yyyy-MM-dd HH:mm:ss").create().toJson(obj);
    }

    public static String toPrettyJsonString(Object obj){
        GsonBuilder gb=new GsonBuilder();
        return gb.setDateFormat("yyyy-MM-dd HH:mm:ss").setPrettyPrinting().create().toJson(obj);
    }

    public static Map<String,Object> toMap(String jsonStr){
        GsonBuilder gb=new GsonBuilder();
        return  gb.enableComplexMapKeySerialization().create().fromJson(jsonStr,HashMap.class);
    }

}
